const storage = window.localStorage || window.sessionStorage

export function setStore(name, content) {
  if (!name) return
  if (typeof content !== 'string') {
    content = JSON.stringify(content)
  }
  storage.setItem(name, content)
}

export function getStore(name) {
  if (!name) return
  return storage.getItem(name)
}

export function removeStore(name) {
  if (!name) return
  storage.removeItem(name)
}

export default {
  set: setStore,
  get: getStore,
  remove: removeStore
}
